#include "config.h"

#define BEEP  (1 << 7)  //18 bit set 1

void __irq irq_Eint0(void) {
	uint32 i = 0;
	i = IO0PIN;
		
	if (0 == (i & BEEP))
		IO0CLR = BEEP;
	else
		IO0SET = BEEP;
	while (0 != (EXTINT & 0x01)) {
		EXTINT = 0x01;
	}
	VICVectAddr = 0;
}

int main(int argc, char **argv) {
	//uint32 i = 0;
	PINSEL0 = 0x00000000;
	PINSEL1 = 0x00000001;  	//key1 p0.16
	IO0DIR = BEEP;			//set p1.18 output
	EXTMODE = 0x00;
	EXTPOLAR = 0x00;
	
	IO0SET = BEEP;
	IRQEnable();
	VICIntSelect=0x00000000;
	VICDefVectAddr = (int)irq_Eint0; 
	EXTINT = 0x01;
	VICIntEnable = 1<<0x0e;
	while (1);
	return 0;
}